﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Collections.Generic;
using Corina.Common;

namespace Corina.Lantern.Hub.Viewmodels
{
    public class HomeViewmodel:ViewmodelBase
    {
        public OperatingSystem OsVersion
        {
            get
            {
                return Environment.OSVersion;
            }
        }

        public string Greetings
        {
            get
            {
                int hour = DateTime.Now.Hour;
                if (hour >= 6 && hour < 9)
                {
                    return "早上好";
                }
                if (hour >= 9 && hour < 11)
                {
                    return "上午好";
                }
                if (hour >= 11 && hour < 13)
                {
                    return "中午好";
                }
                if (hour >= 13 && hour < 17)
                {
                    return "下午好";
                }
                if (hour >= 17 && hour < 20)
                {
                    return "傍晚好";
                }
                if (hour >= 20 && hour < 24)
                {
                    return "晚上好";
                }
                return "凌晨好";
            }
        }

        public string UserName
        {
            get { return DataContext.IsValid ? DataContext.CurrentAccount.Name : ""; }
        }

        public DateTime RegisterTime
        {
            get { return DataContext.IsValid ? DataContext.CurrentAccount.RegisterTime : DateTime.Now; }
        }

        public DateTime LastLogin
        {
            get {
                return DateTime.Now.AddMinutes((0 - new Random().Next(100)));
            }
        }

        public IEnumerable<object> ExpireDeviceCollection
        {
            get
            {
                yield return new { DeviceSn = "129101390", StartTime = "2013-09-28", ExpireTime = "2014-03-27", Remaind = DatetimeHelper.GetDurationDays(Convert.ToDateTime("2014-03-27"), DateTime.Now.Date) };
                yield return new { DeviceSn = "206110039", StartTime = "2013-11-05", ExpireTime = "2014-05-04", Remaind = DatetimeHelper.GetDurationDays(Convert.ToDateTime("2014-05-04"), DateTime.Now.Date) };
                yield return new { DeviceSn = "107149130", StartTime = "2013-11-09", ExpireTime = "2014-05-08", Remaind = DatetimeHelper.GetDurationDays(Convert.ToDateTime("2014-05-08"), DateTime.Now.Date) };
                yield return new { DeviceSn = "060171141", StartTime = "2013-11-09", ExpireTime = "2014-05-08", Remaind = DatetimeHelper.GetDurationDays(Convert.ToDateTime("2014-05-08"), DateTime.Now.Date) };
            }
        }
    }
}
